package org.jinion.constants;

import java.sql.Types;

public enum DataTypeEnum{
	//TODO datatypeCode(-9999) for unSupportType maybe not very reasonable, can prove
	integer(Types.INTEGER),string(Types.VARCHAR),date(Types.DATE),time(Types.TIME),unSupportType(-9999);
	private int datatypeCode;
	DataTypeEnum(int datatypeCode) {
		this.datatypeCode = datatypeCode;
	}
	public int getDatatypeCode() {
		return datatypeCode;
	}
	public static DataTypeEnum matchDataType(int datatypeCode) {
		for(DataTypeEnum dataTypeEnum : DataTypeEnum.values()) {
			if(dataTypeEnum.getDatatypeCode() == datatypeCode) {
				return dataTypeEnum;
			}
		}
		return DataTypeEnum.unSupportType;
	}
}
